package com.NewtifyMe;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class SearchList {

	private HashMap<String, SearchItem> searchList;
	
	public SearchList(){
		searchList = new HashMap<String, SearchItem>();
	}
	
	public void addKeyword(String keyword){
		searchList.put(keyword, new SearchItem(keyword));
	}
	
	public String[] getTitleList(String keyword){
		SearchItem si;
		if (searchList.containsKey(keyword)){
			si = (SearchItem)searchList.get(keyword);
			return si.getTitleList();
		}
		return null;
	}
	
	public String[] getKeywordList(){
		ArrayList<String> list= new ArrayList<String>();
		Set<String> keylist = searchList.keySet();
		
		
		Iterator<String> it = keylist.iterator();
		while(it.hasNext()){
			list.add(it.next());
		}
		String ret[] = new String[list.toArray().length];
		
		for (int i=0; i<list.toArray().length;i++){
			ret[i] = (String)list.toArray()[i];
		}
		return ret;
	}
	
	public HashMap<String, SearchItem> getSearchList() {
		return searchList;
	}

	public void setSearchList(HashMap<String, SearchItem> searchList) {
		this.searchList = searchList;
	}

	public void removeKeyword(String keyword){
		if (searchList.containsKey(keyword))
			searchList.remove(keyword);
	}
	
}
